package com.morontestandroid;

import android.app.Activity;

import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


public class CheckPoint extends Activity implements android.view.View.OnClickListener {
	
	 Chronometer mChronometer;
	 AnimationDrawable AniFrame;
	 
	 public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.check_point);
	  
	        
	        ImageView MyImageView = (ImageView)findViewById(R.id.mushRoomId);
	        MyImageView.setBackgroundResource(R.drawable.run_mushroom);
	        mChronometer = (Chronometer) findViewById(R.id.checkPointChrmId);
	        AniFrame = (AnimationDrawable) MyImageView.getBackground();
	        MyImageView.setOnClickListener(this);
	        
	        mChronometer.setBase(getTime()); 
	  		mChronometer.start();
	        
	        
		       TextView txt = (TextView) findViewById(R.id.custom_font);  
		       Typeface font = Typeface.createFromAsset(getAssets(), "testtext.ttf");  
		        txt.setTypeface(font); 
	 }
	 
	 public long getTime() {
		  Bundle extras = getIntent().getExtras();
		  long time = extras.getLong("time");
		  return time;
		 
	}
	 
	 public void onWindowFocusChanged(boolean hasFocus) {
		 super.onWindowFocusChanged(hasFocus);

          if(hasFocus) 
        	  AniFrame.start();
            
    }

	 public void onClick(View arg0) {
	
		  switch(arg0.getId()) {
		   case R.id.mushRoomId:
			  //AniFrame.start();
				int activityID = 1;
				Intent intent;
				intent = new Intent().setClass(this, SixthLevel.class);
				intent.putExtra("time", getThisBase());
				startActivityForResult(intent, activityID);
		    break;
		  }
	 }
		public void onBackPressed() {
			// do something on back.
			startActivity(new Intent(this, MenyActivity.class));
			return;
			}
		public long getThisBase(){
			  return mChronometer.getBase();
			 
		}

}
